package main.java.Fzy.Test.demo;

import java.sql.*;

public class JDBC {
    static String driver = "com.mysql.jdbc.Driver";
    static String url = "jdbc:mysql://localhost:3306/test1?useSSL=false";
    static String username = "root";
    static String password = "123";

    public static void main(String[] args) throws ClassNotFoundException, SQLException {
        Class.forName(driver);
        Connection conn = DriverManager.getConnection(url, username, password);
        System.out.println("数据库的连接:" + conn);
        String sql = "select * from test1";
        PreparedStatement pstmt = conn.prepareStatement(sql);
        ResultSet rs = pstmt.executeQuery();
        while (rs.next()){
            System.out.println(rs.getString("uid")+rs.getString("uname")+rs.getString("password"));
        }
    }
}
